var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var UI_AddPower_UIBindings = require("AA_UI_AddPower_UIBindings");
var UIView = require("AA_UIView");
var Excel = require("AA_Excel");
var PlayerDataManager = require("AA_PlayerDataManager");
var TipsManager = require("AA_TipsManager");
var ADManager = require("AA_ADManager");
var Const_Hall = require("AA_Const_Hall");
var HallGlobalVariable = require("AA_HallGlobalVariable");
var UIManager = require("AA_UIManager");
var BundleConfig = require("AA_BundleConfig");
var UIConfig_Home = require("AA_UIConfig_Home");
var CommonUtils = require("AA_CommonUtils");
var Const_Common = require("AA_Const_Common");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_AddPower = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onLoad = function () {};
  _creator.prototype._show = function (e) {
    var t = [];
    for (var o = 1; o < arguments.length; o++) {
      t[o - 1] = arguments[o];
    }
    var n = this.auto_ui;
    if (!this.addPowerData) {
      this.addPowerData = Excel.Excel.addPower(1);
      n.txt_addCountLabel.string = "X" + this.addPowerData.addCount;
      n.txt_priceLabel.string = "" + this.addPowerData.price;
      n.txt_videoAddCountLabel.string = "X" + this.addPowerData.videoAddCount;
    }
    n.txt_lastCountLabel.string = "今日剩余" + (this.addPowerData.maxTime - PlayerDataManager.PlayerDataMgr.globalData.addPowerTime) + "次";
    n.txt_videoLastCountLabel.string = "今日剩余" + (this.addPowerData.videoMaxTime - PlayerDataManager.PlayerDataMgr.globalData.videoAddPowerTime) + "次";
  };
  _creator.prototype._clickListener = function (e) {
    var t = this.auto_ui;
    switch (e) {
      case t.btn_closeBtn:
        this._close();
        break;
      case t.btn_addBtn:
        this.BuyThis(false);
        break;
      case t.btn_videoAddBtn:
        this.BuyThis(true);
    }
  };
  _creator.prototype.BuyThis = function (e) {
    var t = this;
    function o(e) {
      var o = new Const_Hall.GetItemsData();
      o.ids = [HallGlobalVariable.default.powerId];
      o.counts = [e ? t.addPowerData.videoAddCount : t.addPowerData.addCount];
      o.clickCallBack = function () {
        if (e) {
          PlayerDataManager.PlayerDataMgr.globalData.videoAddPowerTime++;
          PlayerDataManager.PlayerDataMgr.AddPower(t.addPowerData.videoAddCount);
          t.auto_ui.txt_videoLastCountLabel.string = "今日剩余" + (t.addPowerData.videoMaxTime - PlayerDataManager.PlayerDataMgr.globalData.videoAddPowerTime) + "次";
        } else {
          PlayerDataManager.PlayerDataMgr.globalData.addPowerTime++;
          PlayerDataManager.PlayerDataMgr.AddPower(t.addPowerData.addCount);
          t.auto_ui.txt_lastCountLabel.string = "今日剩余" + (t.addPowerData.maxTime - PlayerDataManager.PlayerDataMgr.globalData.addPowerTime) + "次";
        }
        TipsManager.TipMgr.showToast("体力 +" + (e ? t.addPowerData.videoAddCount : t.addPowerData.addCount));
      };
      UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_GetItems, o);
    }
    if (e && this.addPowerData.videoMaxTime - PlayerDataManager.PlayerDataMgr.globalData.videoAddPowerTime <= 0 || !e && this.addPowerData.maxTime - PlayerDataManager.PlayerDataMgr.globalData.addPowerTime <= 0) {
      TipsManager.TipMgr.showToast("今日剩余次数不足");
    } else if (e) {
      ADManager.ADMgr.showRewardedVideo("视频购买体力", function () {
        o(e);
      });
    } else if (PlayerDataManager.PlayerDataMgr.SubDiamond(this.addPowerData.price)) {
      CommonUtils.default.SendPoint(Const_Common.SendPointType.外围打点, "钻石购买体力");
      o(e);
    }
  };
  __decorate([_property(UI_AddPower_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_AddPower;